Commands > The command API > canAcceptCommand()

 

canAcceptCommand()

Description

Determines whether the command is appropriate for the current selection.

Note: Do not define canAcceptCommand() unless it returns false in at least one case. If the function is not defined, the command is assumed to be appropriate; making this assumption saves time and improves performance.

Arguments

None.

Returns

true if the command is allowed; false if it is not, dimming the command in the menu.

Example

The following instance of canAcceptCommand() makes the command available only when the selection is a table:

function canAcceptCommand(){
	var selObj=dw.getDocumentDOM.getSelectedNode();
	return (selObj.nodeType == Node.ELEMENT_NODE && selObj.tagName=="TABLE");
}